package com.mshop.service;

import java.util.List;

import com.mshop.fw.modules.CommonService;
import com.mshop.po.Manager;
import com.mshop.util.QL;

public class ManagerService extends CommonService {

	public Manager find(String name, String pwd) {
		Manager man = dao.findSingle(Manager.class, QL.HQL.MANAGER.FIND_BY_NAME,
				new Object[] { name });
		if (man != null) {
			String pass = man.getPwd();
			if (pass != null && pass.equals(pwd)) {
				return man;
			} else {
				return null;
			}
		}
		return man;
	}

	public List<Manager> list() {
		return dao.find(Manager.class, QL.HQL.MANAGER.LIST, new Object[] {});
	}

	public void save(Manager manager) {
		dao.save(manager);
	}

	public Manager load(String id) {
		return dao.load(Manager.class, new Long(id));
	}
	
	public Manager get(String id) {
		return dao.get(Manager.class, new Long(id));
	}

	public void delete(String id) {
		dao.delete(this.get(id));
	}
}
